<?
require_once( '../../includes/init.php');

function checkLogin() 
	{
		require_once ('../class_passport.php' );
		$clsPassport = new x_Passport;
		$clsPassport->appId = 10; // 通行证服务ID
		$clsPassport->encryptKey = 'k4kfEOJdi9asUWKKSDXxCKDIfjsoUH5Aa09dnAB'; // 私钥
		/****** 登陆认证 ******/
		// 第一步：
		$clsPassport->verify ();

		// 第二步，保存 Passport 信息到当前程序的 Session
		$userSession = $clsPassport->vars;
		/*
		这里为保存 Session 代码
		*/
		if ( $clsPassport->vars['app_user_id'] > 0 )
		{
			// 若账号已激活表示已登陆当前程序
		}
		// 注：无需每次都验证 Passport，可以先通过用户在当前程序本身的 Session 判断是否已登陆
        //print_r($userSession);die();

		/****** 获取程序列表 ******/
		// $appType : 程序的类型, 系统程序为 1, 游戏为 2
		//$appList = $clsPassport->appGetList ( $appType );
		$_SESSION['union_username'] = $userSession["username"];
		$_SESSION['union_nickname'] = $userSession["nickname"];
		return $_SESSION['union_username'];
	}
if ($_SESSION['union_username'] =='') {
    checkLogin();
}

$smarty->cache_lifetime = 3600;
$smarty->caching = true;
$smarty->use_sub_dirs = true;

$siteObj=alps::newClass('mod_site','mod');

$siteInfo = $siteObj->getSiteInfo($_SERVER['HTTP_HOST']);                                                     //得到站点信息
if (empty($siteInfo)) die('请检查域名是否错误');

header("Content-type: text/html; charset=utf-8"); 
if ($siteInfo['site_status']==3) {
echo "<script>alert('网站审核没有通过');window.close();</script>";die;
}

if (!$_GET['sortid']) die('没有分类id');

switch($_GET['game']) {
	case 102:
		$tplpath='sanguo/';
	break;
	case 101:
		$tplpath='zuqiu1/';
	break;
	case 104:
		$tplpath='zuqiu2/';
	break;
	case 103:
		$tplpath='hero/';
	break;
	default:
		$tplpath='';
}
if ($tplpath=='') die('没有指定游戏');

$my_cache_id=md5($_SERVER['HTTP_HOST']);
if(!$smarty->is_cached($tplpath.'news_list.html',$my_cache_id.'game'.$_GET['game'])) {

	$sortlist = $siteObj->getsortlist(intval($_GET['sortid']),intval($_GET['gsortid']));                           //得到文章分类列表信息
	$smarty->assign('sortlist',$sortlist['result']);
	$smarty->assign('pagebar',$sortlist['pagebar']);
}
if ($_GET['game']==101){
$smarty->assign('backaddress',urlencode($_SERVER['HTTP_HOST']));
$smarty->assign('backurl',$_SERVER['HTTP_HOST'].'/game/?game=101');
}
else
$smarty->assign('backaddress',$_SERVER['HTTP_HOST']);

$cachepath1=substr($my_cache_id,0,2);
$cachepath2=substr($my_cache_id,2,2);
$smarty->display($tplpath.'news_list.html',$cachepath1.'|'.$cachepath2.'|'.$my_cache_id.'|'.'game'.$_GET['game'].'|'.$_GET['sortid'].$_GET['Ps']); 
?>